
require 'mysql'

begin
# connect to the   server
dbh = Mysql.real_connect("127.0.0.1", "root", "", "scada")
# get server version string and display it
puts "Server version: " + dbh.get_server_info
rescue MysqlError => e
puts "Error code: ", e.errno
puts "Error message: ", e.error
ensure
# disconnect from server
dbh.close if dbh
end